package com.parking.mgr.useraccount.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.parking.mgr.common.annotion.BusinessLog;
import com.parking.mgr.common.annotion.LoginAuth;
import com.parking.mgr.common.annotion.PermissionUrl;
import com.parking.mgr.common.enums.LogAnnotionOpTypeEnum;
import com.parking.mgr.common.pojo.page.PageResult;
import com.parking.mgr.common.pojo.response.Result;
import com.parking.mgr.useraccount.model.param.UpdateUserInfoParam;
import com.parking.mgr.useraccount.model.param.UserInfoParam;
import com.parking.mgr.useraccount.model.param.UserRoleParam;
import com.parking.mgr.useraccount.model.vo.UserFullInfoVO;
import com.parking.mgr.useraccount.model.vo.UserInfoVO;
import com.parking.mgr.useraccount.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.List;

/**
 * @ClassName BasicUserController
 * @Description 系统用户控制器
 * @Auther: zhijianpu
 * @Date: 2023/5/25
 */
@Api(value = "用户信息", tags = {"用户信息"})
@RequestMapping("/api/user")
@RestController
public class UserInfoController {

    @Resource
    private UserInfoService userInfoService;

    @PostMapping("/info/add")
    @ApiOperation(value = "注册用户", notes = "注册用户", httpMethod = "POST")
    @BusinessLog(title = "注册用户")
    public Result<?> addUserInfo(@RequestBody @Validated(UserInfoParam.add.class) UserInfoParam userInfoParam) {
        userInfoService.addUserInfo(userInfoParam);
        return Result.success();
    }

    @PostMapping("/info/code")
    @ApiOperation(value = "获取短信验证码", notes = "获取短信验证码", httpMethod = "POST")
    @BusinessLog(title = "获取短信验证码")
    public Result<?> getSmsCode(@ApiParam(name = "phone", value = "phone", required = true)
                                @RequestParam(name = "phone", required = true) String phone) {
        return Result.success(userInfoService.getSmsCode(phone));
    }

//    @PostMapping("/info/edit")
//    @ApiOperation(value = "编辑用户信息", notes = "编辑用户信息", httpMethod = "POST")
//    @BusinessLog(title = "编辑用户信息", opType = LogAnnotionOpTypeEnum.EDIT)
//    @LoginAuth
//    @PermissionUrl
//    public Result<?> editUserInfo(@RequestBody @Validated(UpdateUserInfoParam.edit.class) UpdateUserInfoParam updateUserInfoParam) {
//        userInfoService.editUserInfo(updateUserInfoParam);
//        return Result.success();
//    }

//    @PostMapping("/info/editself")
//    @ApiOperation(value = "编辑用户信息(登录用户)", notes = "编辑用户信息(登录用户)", httpMethod = "POST")
//    @BusinessLog(title = "编辑用户信息(登录用户)", opType = LogAnnotionOpTypeEnum.EDIT)
//    @LoginAuth
//    @PermissionUrl
//    public Result<?> editUserSelfInfo(@RequestBody @Validated(UpdateUserInfoParam.editSelf.class) UpdateUserInfoParam updateUserInfoParam, HttpServletRequest request) {
//        userInfoService.editUserSelfInfo(updateUserInfoParam, request);
//        return Result.success();
//    }


//    @PostMapping("/info/delete")
//    @ApiOperation(value = "删除非登录用户信息", notes = "删除非登录用户信息", httpMethod = "POST")
//    @BusinessLog(title = "删除非登录用户信息", opType = LogAnnotionOpTypeEnum.DELETE)
//    @LoginAuth
//    @PermissionUrl
//    public Result<?> deleteUserInfo(@ApiParam(name = "id", value = "id", required = true)
//                                        @RequestParam(name = "id", required = true)
//                                        Collection<String> ids) {
//        userInfoService.deleteUserInfo(ids);
//        return Result.success();
//    }

//    @GetMapping("/info/list")
//    @ApiOperation(value = "用户信息列表（分页）", notes = "用户信息列表（分页）", httpMethod = "GET")
//    @BusinessLog(title = "用户信息列表（分页）", opType = LogAnnotionOpTypeEnum.PAGE)
//    @LoginAuth
//    @PermissionUrl
//    public Result<?> listUserInfo(UserInfoParam userInfoParam) {
//        IPage<UserInfoVO> pageList = userInfoService.listUserInfo(userInfoParam);
//        List<UserInfoVO> records = pageList.getRecords();
//        PageResult<UserInfoVO> pageResult = new PageResult<>((Page) pageList) ;
//        return Result.success(records, pageResult);
//    }

//    @GetMapping("/info/listfull")
//    @ApiOperation(value = "用户完整信息列表（分页）", notes = "用户完整信息列表（分页）", httpMethod = "GET")
//    @BusinessLog(title = "用户完整信息列表（分页）", opType = LogAnnotionOpTypeEnum.PAGE)
//    @LoginAuth
//    @PermissionUrl
//    public Result<?> listUserInfoFull(UserInfoParam userInfoParam) {
//        IPage<UserFullInfoVO> pageList = userInfoService.listUserInfoFull(userInfoParam);
//        List<UserFullInfoVO> records = pageList.getRecords();
//        PageResult<UserFullInfoVO> pageResult = new PageResult<>((Page) pageList) ;
//        return Result.success(records, pageResult);
//    }


//    @GetMapping("/info/detail")
//    @ApiOperation(value = "获取用户信息", notes = "获取用户信息", httpMethod = "GET")
//    @BusinessLog(title = "获取用户信息", opType = LogAnnotionOpTypeEnum.QUERY)
//    @LoginAuth
//    @PermissionUrl
//    public Result<?> queryUserInfo(HttpServletRequest request) {
//        return Result.success(userInfoService.detail(request));
//    }

//    @GetMapping("/account/detail/byuserinfoid")
//    @ApiOperation(value = "获取用户信息", notes = "获取用户信息", httpMethod = "GET")
//    @BusinessLog(title = "获取用户信息", opType = LogAnnotionOpTypeEnum.QUERY)
//    @LoginAuth
//    @PermissionUrl
//    public Result<?> getUserByUserInfoId(@ApiParam(name = "id", value = "id", required = true)
//                                             @RequestParam(name = "id", required = true) String id, HttpServletRequest request) {
//        return Result.success(userInfoService.getUserByUserInfoId(id));
//    }

//    @PostMapping("/info/assignrole")
//    @ApiOperation(value = "为用户分配角色", notes = "为用户分配角色", httpMethod = "POST")
//    @BusinessLog(title = "为用户分配角色")
//    @LoginAuth
//    @PermissionUrl
//    public Result<?> setRoleUser(@RequestBody @Validated(UserRoleParam.add.class) UserRoleParam userRoleParam) {
//        userInfoService.setRoleUser(userRoleParam);
//        return Result.success();
//    }

//    @GetMapping("/info/roleuserlist")
//    @ApiOperation(value = "用户已分配角色", notes = "用户已分配角色", httpMethod = "GET")
//    @BusinessLog(title = "用户已分配角色", opType = LogAnnotionOpTypeEnum.QUERY)
//    @LoginAuth
//    @PermissionUrl
//    public Result<?> roleUserList(
//            @ApiParam(name = "id", value = "id", required = true)
//            @RequestParam(name = "id") String id
//    ) {
//        return Result.success(userInfoService.roleUserList(id));
//    }

//    @GetMapping("/info/roleusermenulist")
//    @ApiOperation(value = "登录用户所属角色的功能菜单列表", notes = "登录用户所属角色的功能菜单列表", httpMethod = "GET")
//    @BusinessLog(title = "登录用户所属角色的功能菜单列表", opType = LogAnnotionOpTypeEnum.QUERY)
//    @PermissionUrl
//    public Result<?> getRoleUserMenuList(HttpServletRequest request) {
//        return Result.success(userInfoService.getRoleUserMenuList(request));
//    }

}
